package com.hjx.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.Test;

public class Threadpool {

    private static ExecutorService pool = Executors.newFixedThreadPool(3);
    @Test
    public void test() throws InterruptedException {

        for (;;) {
            Thread.sleep(1000);
            pool.submit(new Runnable() {
                @Override public void run() {


                    System.out.println(Thread.currentThread().getName() + "运行中");
                    throw new RuntimeException("xxxxxxxxxxxx");
                }
            });
        }

    }

    public static void main(String[] args) throws InterruptedException {
        for (;;) {
            Thread.sleep(1000);
            pool.submit(new Runnable() {
                @Override public void run() {
                    try {
                        System.out.println(Thread.currentThread().getName() + "运行中");
                        throw new RuntimeException("xxxxxxxxxxxx");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }


                }
            });
        }

    }
}
